<template>
  <div class="item" @click="toStore">
    <img :src="itemContent.pic" class="item-img">
    <div class="item-info">
      <div class="item-title">{{ itemContent.title }}</div>
      <div class="item-sales">月售{{ itemContent.sales }}单</div>
      <div class="item-price">¥{{ itemContent.price }}</div>
      <div class="item-labels">
        <span v-for="(label, index) in itemContent.label" :key="index" class="label">{{ label }}</span>
      </div>
    </div>
  </div>
</template>

<script>
import { useRouter } from 'vue-router';

export default {
  props: ["itemContent"],
  setup() {
    const router = useRouter()
    const toStore = () => {
      router.push("/store")
    }
    return {
      toStore
    }
  }
}
</script>

<style scoped lang="less">
.item {
  display: flex;
  padding: 10px 0;
  border-bottom: 1px solid #eee;

  .item-img {
    width: 120px;
    height: 90px;
    border-radius: 4px;
    margin-right: 10px;
  }

  .item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    .item-title {
      font-size: 16px;
      font-weight: 600;
    }

    .item-sales {
      font-size: 12px;
      color: #666;
    }

    .item-price {
      color: #ff6b00;
      font-size: 16px;
      font-weight: 600;
    }

    .item-labels {
      display: flex;
      gap: 5px;

      .label {
        font-size: 12px;
        color: #ff6b00;
        background: #fff5e6;
        padding: 2px 4px;
        border-radius: 2px;
      }
    }
  }
}
</style>